package com.example.springcloudjwtserver.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.springcloudjwtserver.user.domain.AdminUser;
import com.example.springcloudjwtserver.user.service.AdminUserService;
import com.example.springcloudjwtserver.user.mapper.AdminUserMapper;
import com.example.springcloudjwtserver.util.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser>
implements AdminUserService{
    @Autowired
    private AdminUserMapper adminUserMapper;

    public AdminUser login(String userName, String pwd) {
        QueryWrapper<AdminUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(AdminUser::getTel, userName)
                .eq(AdminUser::getPwd, pwd);
        AdminUser adminUser = adminUserMapper.selectOne(queryWrapper);
        return adminUser;
    }

    @Override
    public boolean verify(String jwt) {

        return JwtUtil.verifyJwt(jwt);
    }

}




